import request from '@/utils/request'

export const getuser = (params: any) =>
  request({
    url: '/user',
    method: 'post',
    params
  })

export const getUserInfo = (data: any) =>
  request({
    url: '/user/view',
    method: 'post',
    data
  })

export const getUserByName = (username: string) =>
  request({
    url: `/user/${username}`,
    method: 'post'
  })

export const updateUser = (username: string, data: any) =>
  request({
    url: `/user/${username}`,
    method: 'post',
    data
  })

export const deleteUser = (username: string) =>
  request({
    url: `/user/${username}`,
    method: 'post'
  })

export const login = (data: any) =>
  request({
    url: '/user/login',
    method: 'post',
    data
  })

export const logout = () =>
  request({
    url: '/user/logout',
    method: 'post'
  })

export const register = (data: any) =>
  request({
    url: '/user/signup',
    method: 'post',
    data
  })

export const resentEmail = (data: any) =>
  request({
    url: '/user/request-password-reset',
    method: 'post',
    data
  })

export const resetPassword = (data: any) =>
  request({
    url: '/user/reset-password',
    method: 'post',
    data
  })
export const getRegisterMsgCode = (mobile: string) =>
  request({
    url: '/user/send-verify-code',
    method: 'post',
    data: { scene: 'register', mobile }
  })
export const getResetMsgCode = (mobile: string) =>
  request({
    url: '/user/send-verify-code',
    method: 'post',
    data: { scene: 'reset_password', mobile }
  })
export const getSysConfig = () =>
  request({
    url: '/config/index',
    method: 'post'
  })
